﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LotteryHelper
{
    public partial class NumChooseCtrl : UserControl
    {
        public string SelectedNum
        {
            get { return GetNum();}
        }

        public NumChooseCtrl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 选中所有的
        /// </summary>
        public void SelectedAll()
        {
            foreach (Control ctrl in Controls)
            {
                if (ctrl is CheckBox)
                {
                    CheckBox ch = (CheckBox)ctrl;
                    ch.Checked = true;
                }
            }
        }

        /// <summary>
        /// 清除所有的数值
        /// </summary>
        public void DeSelectedAll()
        {
            foreach (Control ctrl in Controls)
            {
                if (ctrl is CheckBox)
                {
                    CheckBox ch = (CheckBox)ctrl;
                    ch.Checked = false;
                }
            }
        }

        /// <summary>
        /// 获取选中的数值
        /// </summary>
        /// <returns></returns>
        private string GetNum()
        {
            string strNum = "";
            if (radioButton0.Checked)
            {
                strNum += "0";
            }
            if (radioButton1.Checked)
            {
                strNum += "1";
            }
            if (radioButton2.Checked)
            {
                strNum += "2";
            }
            if (radioButton3.Checked)
            {
                strNum += "3";
            }
            if (radioButton4.Checked)
            {
                strNum += "4";
            }
            if (radioButton5.Checked)
            {
                strNum += "5";
            }
            if (radioButton6.Checked)
            {
                strNum += "6";
            }
            if (radioButton7.Checked)
            {
                strNum += "7";
            }
            if (radioButton8.Checked)
            {
                strNum += "8";
            }
            if (radioButton9.Checked)
            {
                strNum += "9";
            }

            return strNum;
        }
    }
}
